package database;

import java.sql.*;
import javax.sql.*;
import javax.naming.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;


public class TiendaOnLineDAO {

    private ArrayList books;
    Connection con;
    public static String url = "jdbc:derby://localhost:1527/tiendaOnLine";
    public static String dbdriver = "org.apache.derby.jdbc.ClientDriver";
    public static String username = "app";
    public static String password = "app";

    public TiendaOnLineDAO() throws Exception {
        try {
            Class.forName(dbdriver);
            con = DriverManager.getConnection(url, username, password);
            
            System.out.println("Se conecto satisfactoriamente!!"); 
            
        } catch (Exception ex) {
            throw new Exception("No se puede conectar a una base de datos!!!!!!!!!!!" + ex.getMessage());
        }
    }

    public void remove() {
        try {
            con.close();
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
    }

    public static void main(String[] arg) {
        try {
            new TiendaOnLineDAO();
        } catch (Exception ex) {
            System.out.println(ex.getMessage());
        }
    }
}
